package com.hl.sfzy.service;


import com.hl.sfzy.mapper.SearchArticleMapper;
import com.hl.sfzy.mapper.SearchCourseMapper;
import com.hl.sfzy.mapper.SearchExpertMapper;
import com.hl.sfzy.mapper.SearchQuestionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class SearchAllService {
    @Autowired
    private SearchArticleMapper searchArticleMapper;
    @Autowired
    private SearchCourseMapper searchCourseMapper;
    @Autowired
    private SearchTestService searchTestService;
    @Autowired
    private SearchQuestionMapper searchQuestionMapper;
    @Autowired
    private SearchExpertMapper searchExpertMapper;

    public Map<String, Object> searchAll(String query) {
        Map<String, Object> result = new HashMap<>();

        result.put("articles", searchArticleMapper.searchArticles(query));
        result.put("courses", searchCourseMapper.searchCourses(query));
        result.put("tests", searchTestService.searchTests(query));
        result.put("questions", searchQuestionMapper.searchQuestions(query));
        result.put("experts", searchExpertMapper.searchExperts(query));

        return result;
    }
}
